﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SaunaClient.Model.Network
{
    /// <summary>
    /// Tcp Gateway Factory Class
    /// </summary>
    /// <dates>
    /// 28/09/2011 - created by Chiaki Sato
    /// </dates>
    public class TcpFactoryImplementation : ITcpFactory
    {
        private const string ERR_MESSAGE_CLASS_NOT_FOUND = "ITcpFactory can not create: {0}";
        private const string CLASS_NAME_TCP_SSL = "TcpSsl";

        /// <summary>
        /// Constructor
        /// </summary>
        public TcpFactoryImplementation() 
        {
        }

        /// <summary>
        /// Make each TCP/IP communication class
        /// </summary>
        /// <param name="name">Tcp type name</param>
        /// <param name="networkSetting">Network Setting</param>
        public ITcpDaoGateway Make(string name, NetworkSetting networkSetting)
        {
            ITcpDaoGateway iTcpDaoGateway = null;

            switch (name)
            {

                // Create TCP SSL class
                case CLASS_NAME_TCP_SSL:
                    iTcpDaoGateway = TcpDaoGatewaySsl.Instance(networkSetting);
                    return iTcpDaoGateway;

                default:
                    throw new Exception(String.Format(ERR_MESSAGE_CLASS_NOT_FOUND, name));
            }
        }
    }
}
